<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:slctrls="http://schemas.xceed.com/silverlight/xaml/controls"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:System;assembly=mscorlib">

   <LinearGradientBrush x:Key="SilverlightFilterControlButtonDefaultBackgroundBrush"
                        StartPoint="0.5,0"
                        EndPoint="0.5,1">
      <GradientStop Color="#FFFBFBFB"
                    Offset="0" />

      <GradientStop Color="#FFD6DBDF"
                    Offset="1" />
   </LinearGradientBrush>

   <LinearGradientBrush x:Key="SilverlightClearFilterControlButtonPressedBackgroundBrush"
                        StartPoint="0.5,0"
                        EndPoint="0.5,1.04">
      <GradientStop Color="#FFe1ecf6"
                    Offset="0" />

      <GradientStop Color="#FFd5e5f2"
                    Offset="0.3" />

      <GradientStop Color="#FFaecee8"
                    Offset="0.5" />

      <GradientStop Color="#FF75abd8"
                    Offset="1" />
   </LinearGradientBrush>

   <LinearGradientBrush x:Key="SilverlightClearFilterControlButtonDefaultBorderBrush"
                        EndPoint="0.5,1"
                        StartPoint="0.5,0">
      <GradientStop Color="#FFCFD0D0"
                    Offset="0" />

      <GradientStop Color="#FFC9CACA"
                    Offset="1" />
   </LinearGradientBrush>

   <Style x:Key="silverlightClearFilterControlButtonStyle"
          TargetType="Button">

      <Setter Property="Cursor"
              Value="Hand" />

      <Setter Property="Padding"
              Value="5" />

      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="Button">
               <Grid x:Name="grid"
                     Background="Transparent">

                  <ContentPresenter x:Name="contentPresenter"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    Content="{TemplateBinding Content}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Margin="{TemplateBinding Padding}"/>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!--**************************
    * TEMPLATE: FilterControl
    ************************** -->
   <ControlTemplate x:Key="filterControlTemplate"
                    TargetType="slctrls:FilterControl">
      <Grid x:Name="rootLayout">
         <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
               <VisualState x:Name="Normal" />
                <VisualState x:Name="Disabled">
                 <Storyboard>
                  <DoubleAnimation Storyboard.TargetName="rootLayout"
                                   Storyboard.TargetProperty="Opacity"
                                   To="0.5"
                                   Duration="0"/>
                  </Storyboard>
                 </VisualState>
               <VisualState x:Name="MouseOver" />
            </VisualStateGroup>

            <VisualStateGroup x:Name="FocusStates">
               <VisualState x:Name="Unfocused" />
               <VisualState x:Name="Focused" />
            </VisualStateGroup>
         </VisualStateManager.VisualStateGroups>

         <slctrls:SearchTextBox x:Name="searchTextBox"
                                FilterExpression="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=UIFilterExpression, Mode=TwoWay}"
                                FilteredFieldNames="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(slctrls:SearchTextBox.FilteredFieldNames)}"
                                TooComplexText="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(slctrls:SearchTextBox.TooComplexText)}" />
      </Grid>
   </ControlTemplate>

   <!--**************************
    * STYLE: FilterControl
    ************************** -->
   <Style TargetType="slctrls:FilterControl">
      <Setter Property="MinHeight"
              Value="24" />

      <Setter Property="ClearFilterButtonVisibility"
              Value="Collapsed"/>

      <Setter Property="Template"
              Value="{StaticResource filterControlTemplate}"/>
   </Style>

   <ControlTemplate x:Key="searchTextBoxTemplate" 
                    TargetType="slctrls:SearchTextBox">
      <Grid x:Name="RootElement">
         <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
               <VisualState x:Name="Normal" />

                    <VisualState x:Name="Disabled" >
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="RootElement"
                                      Storyboard.TargetProperty="Opacity"
                                      Duration="0"
                                      To=".40" />
                        </Storyboard>
                    </VisualState>

                  <VisualState x:Name="MouseOver">
                  <Storyboard>
                     <ColorAnimation Duration="0"
                                     To="#FF2F77D4"
                                     Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
                                     Storyboard.TargetName="border"/>
                  </Storyboard>
               </VisualState>
               <VisualState x:Name="Pressed">
                  <Storyboard>
                     <ColorAnimation Duration="0"
                                     To="#FF2F77D4"
                                     Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
                                     Storyboard.TargetName="border"/>
                  </Storyboard>
               </VisualState>

               <VisualState x:Name="ReadOnly" />
            </VisualStateGroup>

            <VisualStateGroup x:Name="WatermarkStates">
               <VisualState x:Name="WatermarkVisible">
                  <Storyboard>
                     <DoubleAnimation Storyboard.TargetName="WatermarkPresenter"
                                               Storyboard.TargetProperty="Opacity"
                                               To="0.7"
                                               Duration="00:00:00.000" />
                  </Storyboard>
               </VisualState>

               <VisualState x:Name="WatermarkHidden">
                  <Storyboard>
                     <DoubleAnimation Storyboard.TargetName="WatermarkPresenter"
                                               Storyboard.TargetProperty="Opacity"
                                               To="0"
                                               Duration="00:00:00.000" />
                  </Storyboard>
               </VisualState>
            </VisualStateGroup>

            <VisualStateGroup x:Name="FilterStates">
               <VisualState x:Name="NoFilter" />
               <VisualState x:Name="HasFilter">
                  <Storyboard>
                     <DoubleAnimation Storyboard.TargetName="searchIconPresenter"
                                      Storyboard.TargetProperty="Opacity"
                                      To="0"
                                      Duration="00:00:00.000" />
                     <ObjectAnimationUsingKeyFrames Duration="0"
                                                    Storyboard.TargetProperty="Visibility"
                                                    Storyboard.TargetName="ClearFilterButton">
                        <DiscreteObjectKeyFrame KeyTime="0">
                           <DiscreteObjectKeyFrame.Value>
                              <Visibility>Visible</Visibility>
                           </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                     </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
               </VisualState>

               <!-- Filter is too complex or too large to be displayed, only display filterTooComplexTextBlock-->
               <VisualState x:Name="TooComplex">
                  <Storyboard>
                     <ObjectAnimationUsingKeyFrames Duration="0"
                                                    Storyboard.TargetProperty="Visibility"
                                                    Storyboard.TargetName="ContentElement">
                        <DiscreteObjectKeyFrame KeyTime="0">
                           <DiscreteObjectKeyFrame.Value>
                              <Visibility>Collapsed</Visibility>
                           </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                     </ObjectAnimationUsingKeyFrames>

                     <ObjectAnimationUsingKeyFrames Duration="0"
                                                    Storyboard.TargetProperty="Visibility"
                                                    Storyboard.TargetName="WatermarkPresenter">
                        <DiscreteObjectKeyFrame KeyTime="0">
                           <DiscreteObjectKeyFrame.Value>
                              <Visibility>Collapsed</Visibility>
                           </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                     </ObjectAnimationUsingKeyFrames>

                     <ObjectAnimationUsingKeyFrames Duration="0"
                                                    Storyboard.TargetProperty="Visibility"
                                                    Storyboard.TargetName="FilterTooComplexTextBlock">
                        <DiscreteObjectKeyFrame KeyTime="0">
                           <DiscreteObjectKeyFrame.Value>
                              <Visibility>Visible</Visibility>
                           </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                     </ObjectAnimationUsingKeyFrames>

                  </Storyboard>
               </VisualState>
            </VisualStateGroup>

            <VisualStateGroup x:Name="FocusStates">
               <VisualState x:Name="Unfocused" />
               <VisualState x:Name="Focused">
                  <Storyboard>
                     <ColorAnimation Duration="0"
                                     To="#FF2F77D4"
                                     Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
                                     Storyboard.TargetName="border" />
                  </Storyboard>
               </VisualState>
            </VisualStateGroup>


         </VisualStateManager.VisualStateGroups>

         <Border x:Name="border"
                 CornerRadius="10"
                 Grid.ColumnSpan="2">
            <Border.Effect>
               <DropShadowEffect ShadowDepth="0"
                                 Color="#FF7B95B6"
                                 BlurRadius="6"
                                 Opacity="0.75" />
            </Border.Effect>
            <Border.Background>
               <LinearGradientBrush EndPoint="0.5,1"
                                    StartPoint="0.5,0">
                  <GradientStop Color="White"
                                Offset="1" />
                  <GradientStop Color="#FFF4F5F6" />
               </LinearGradientBrush>
            </Border.Background>
         </Border>

         <Grid Margin="8,0,0,0"
               VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="*"/>
               <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <ScrollViewer x:Name="ContentElement"
                          Foreground="White"
                          Padding="{TemplateBinding Padding}"
                          BorderThickness="0"
                          IsTabStop="False" />

            <ContentPresenter x:Name="WatermarkPresenter"
                              IsHitTestVisible="False"
                              Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WatermarkContent, Mode=OneWay}"
                              ContentTemplate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WatermarkContentTemplate, Mode=OneWay}"/>

            <TextBlock x:Name="FilterTooComplexTextBlock"
                       Text="{TemplateBinding TooComplexText}"
                       Visibility="Collapsed"/>
            <ContentPresenter x:Name="searchIconPresenter"
                              Margin="0,0,6,0"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Grid.Column="1"
                              IsHitTestVisible="False">
            <Path x:Name="searchIcon"
                  Height="15.482994079589844"
                  Width="15.4462890625"
                  Stretch="Fill"
                  Opacity="1"
                  Data="M 13.68194580078125,10.379951477050781 C16.034423828125,8.005409240722656 16.034423828125,4.1550140380859375 13.68194580078125,1.7809066772460938 11.3294677734375,-0.5936355590820312 7.51531982421875,-0.5936355590820312 5.163330078125,1.7809066772460938 3.22637939453125,3.7360000610351562 2.8876953125,6.690315246582031 4.1407470703125,8.999420166015625 4.1407470703125,8.999420166015625 0.194580078125,13.024307250976562 0.194580078125,13.024307250976562 -0.185791015625,13.408218383789062 0.00872802734375,14.225440979003906 0.6273193359375,14.85028076171875 1.245849609375,15.4742431640625 2.05596923828125,15.67010498046875 2.43585205078125,15.287055969238281 2.43585205078125,15.287055969238281 6.34381103515625,11.300300598144531 6.34381103515625,11.300300598144531 8.65679931640625,12.691230773925781 11.69183349609375,12.388778686523438 13.68194580078125,10.379951477050781 zM 7.2255859375,8.297897338867188 C6.01239013671875,7.0733642578125 6.0128173828125,5.087066650390625 7.22601318359375,3.8629684448242188 8.438720703125,2.638427734375 10.406494140625,2.638427734375 11.61968994140625,3.8629684448242188 12.83197021484375,5.086631774902344 12.83282470703125,7.07379150390625 11.61968994140625,8.298332214355469 10.40740966796875,9.522430419921875 8.4378662109375,9.522003173828125 7.2255859375,8.297897338867188 z"
                  Fill="#7691b4"/>   
            </ContentPresenter>


            <Button x:Name="ClearFilterButton"
                    Visibility="Collapsed"
                    Grid.Column="1"
                    IsTabStop="False"                    
                    Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ClearFilterCommand}"
                    Style="{StaticResource silverlightClearFilterControlButtonStyle}">
               <Path Height="8.485282897949219"
                     Width="8.4853515625"
                     Stretch="Fill"
                     Opacity="1"
                     Data="M 691.828369140625,108.75736236572266 C691.828369140625,108.75736236572266 689,111.58578491210938 689,111.58578491210938 689,111.58578491210938 686.171630859375,108.75736236572266 686.171630859375,108.75736236572266 686.171630859375,108.75736236572266 684.75732421875,110.17156982421875 684.75732421875,110.17156982421875 684.75732421875,110.17156982421875 687.5858154296875,113 687.5858154296875,113 687.5858154296875,113 684.75732421875,115.82843017578125 684.75732421875,115.82843017578125 684.75732421875,115.82843017578125 686.171630859375,117.24264526367188 686.171630859375,117.24264526367188 686.171630859375,117.24264526367188 689,114.41421508789062 689,114.41421508789062 689,114.41421508789062 691.828369140625,117.24264526367188 691.828369140625,117.24264526367188 691.828369140625,117.24264526367188 693.24267578125,115.82843017578125 693.24267578125,115.82843017578125 693.24267578125,115.82843017578125 690.4141845703125,113 690.4141845703125,113 690.4141845703125,113 693.24267578125,110.17156982421875 693.24267578125,110.17156982421875 693.24267578125,110.17156982421875 691.828369140625,108.75736236572266 691.828369140625,108.75736236572266 z"
                     Fill="#859dbb"
                     HorizontalAlignment="Center"
                     VerticalAlignment="Center"
                     UseLayoutRounding="False"
                     Grid.Column="1"
                     Margin="0,0,3,0" />
            </Button>
         </Grid>

      </Grid>
   </ControlTemplate>

   <!--**************************
    * STYLE: SearchTextBox
    ************************** -->
   <Style TargetType="slctrls:SearchTextBox">

      <Setter Property="Foreground"
              Value="#769DC4" />

      <Setter Property="FontStyle"
              Value="Italic" />

      <Setter Property="Padding"
              Value="0" />

      <Setter Property="WatermarkContent"
              Value="Search"/>

      <Setter Property="Template"
              Value="{StaticResource searchTextBoxTemplate}"/>
   </Style>

</ResourceDictionary>
